<!--
 * @Author: hutong huareu980@163.com
 * @Date: 2023-05-29 17:57:07
 * @LastEditors: hutong huareu980@163.com
 * @LastEditTime: 2023-06-15 14:02:10
 * @FilePath: /smart-web-app/pages/index.vue
 * @Description: 
-->
<template>
  <div class="pages">
    <Swiper
      :modules="[
        SwiperAutoplay,
        SwiperEffectCreative,
        SwiperController,
        SwiperNavigation,
        SwiperEffectFlip,
      ]"
      :slides-per-view="1"
      :loop="true"
      :effect="'creative'"
      :autoplay="{
        delay: 3000,
        disableOnInteraction: true,
      }"
      :creative-effect="{
        prev: {
          shadow: false,
          translate: ['-20%', 0, -1],
        },
        next: {
          translate: ['100%', 0, 0],
        },
      }"
      class="swiper-box"
    >
      <SwiperSlide v-for="item in bannerList" :key="item.id">
        <img :src="item.picture_url" alt="" />
      </SwiperSlide>
    </Swiper>
    <div class="container">
      <h2>{{ t("home.title") }}</h2>
      <div class="content-box" v-html="info.content"></div>
      <div class="grid-box">
        <div class="grid-left">
          <div class="grid-left__item">
            <div class="img-box">
              <img
                :src="info?.children?.[0]?.images?.[0]"
                alt="加载中..."
                v-if="info?.children?.[0]?.images?.[0]"
              />
              <img src="~/assets/image/16.jpg" alt="加载中..." v-else />
              <div class="tip-box">
                <img src="~/assets/image/icon_s4.png" />
                <span>{{ info.children?.[0]?.title }}</span>
                <div class="learn-more">
                  <NuxtLink :to="localePath('/content/53/54', locale)">{{
                    $t("home.more")
                  }}</NuxtLink>
                </div>
              </div>
            </div>
            <div class="img-box">
              <img
                :src="info?.children?.[2]?.images?.[0]"
                alt="加载中..."
                v-if="info?.children?.[2]?.images?.[0]"
              />
              <img src="~/assets/image/05.jpg" alt="加载中..." v-else />
              <div class="tip-box">
                <img src="~/assets/image/icon_s4.png" />
                <span>{{ info.children?.[2]?.title }}</span>
                <div class="learn-more">
                  <NuxtLink :to="localePath('/content/53/56', locale)">{{
                    $t("home.more")
                  }}</NuxtLink>
                </div>
              </div>
            </div>
          </div>
          <div class="grid-left__item">
            <div class="img-box">
              <img src="~/assets/image/33.jpg" alt="加载中..." />
              <div class="tip-box">
                <img src="~/assets/image/icon_s4.png" />
                <span>......</span>
                <div class="learn-more">
                  <NuxtLink :to="localePath('/content/48/49', locale)">{{
                    $t("home.more")
                  }}</NuxtLink>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="grid-right">
          <div class="img-box">
            <img
              :src="info?.children?.[1]?.images?.[0]"
              alt="加载中..."
              v-if="info?.children?.[1]?.images?.[0]"
            />
            <img src="~/assets/image/35.jpg" alt="加载中..." v-else />
            <div class="tip-box">
              <img src="~/assets/image/icon_s4.png" />
              <span>{{ info.children?.[1]?.title }}</span>
              <div class="learn-more">
                <NuxtLink :to="localePath('/content/53/55', locale)">{{
                  $t("home.more")
                }}</NuxtLink>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const { locale, t } = useI18n();
const localePath = useLocalePath();
const bannerList = ref<any>([]);
const { data } = <any>await useGetFetch("/t/53", { lang: locale.value });
const { data: banner } = <any>await useGetFetch("/b", { lang: locale.value });
bannerList.value = banner.value.result.map((item: any) => {
  return {
    id: item.id,
    picture_url: oss_url + "/" + item.picture_url,
  };
});
const { info } = useContentInfo(data.value.result);
</script>
<style scoped lang="scss">
.swiper-box {
  height: 520px;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.container {
  padding: 60px 0 30px;
  h2 {
    position: relative;
    padding-left: 20px;
    font-size: 32px;
    line-height: 32px;
    &::before {
      content: "";
      position: absolute;
      left: 0;
      width: 4px;
      height: 100%;
      background-color: $primary;
    }
  }
  .content-box {
    margin-top: 20px;
    font-size: 21px;
  }
  .grid-box {
    display: flex;
    width: 100%;
    height: 485px;
    margin-top: 10px;
    overflow: hidden;
    img {
      object-fit: cover;
    }
    .img-box {
      width: 100%;
      height: 100%;
      opacity: 0.8;
      position: relative;
      &:hover {
        opacity: 1;
        .tip-box {
          bottom: 0;
        }
      }
      .tip-box {
        position: absolute;
        width: 100%;
        padding: 35px;
        box-sizing: border-box;
        bottom: -80px;
        display: flex;
        flex-direction: column;
        transition: all 300ms ease 0ms;

        .learn-more {
          background-color: $primary;
          color: #fff;
          width: 100px;
          display: flex;
          align-items: center;
          justify-content: center;
          height: 30px;
          border-radius: 50px;
          margin-top: 20px;
          cursor: pointer;
          a {
            color: #fff;
          }
        }
        // &:hover {
        //   bottom: 0;
        //   .learn-more {
        //     // display: block;
        //   }
        // }
        img {
          width: 70px;
        }
        span {
          color: #fff;
          font-size: 24px;
        }
      }
      & + .img-box {
        margin-left: 20px;
      }
      img {
        width: 100%;
        height: 100%;
      }
    }
    .grid-left {
      flex: 1;
      height: 100%;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      &__item {
        flex: 1;
        display: flex;
        overflow: hidden;
        & + .grid-left__item {
          margin-top: 20px;
        }
      }
    }
    .grid-right {
      margin-left: 20px;
      width: 30%;
      height: 100%;
    }
  }
}
</style>
